import { FieldRule } from "vant";
import { PopoverAction } from "vant"
import { VNode } from "vue"

export interface interForm {
    prop: string
    label: string
    width?: string | number
    show?: ({ data, type, isPhone }: { data: any, type: 'form' | 'detail' | 'search', isPhone: boolean }) => boolean
    inpDisabled?: boolean
    vform?: (prop: string, data: any, value: any) => VNode
    p_vform?: (prop: string, data: any, value: any) => VNode
    required?: boolean
    formatter?: (prop: string, data: any, value: any) => VNode | string | undefined
    hformatter?: (prop: string, data: any, value: any) => string | undefined
    p_formatter?: (prop: string, data: any, value: any) => VNode | string | undefined
    rule?: FieldRule[]
    type?: 'number' | 'textarea' | 'password'
    maxlength?: number
    placeholder?: string
    link?: boolean
    overflow?: boolean
}

export interface interTable {
    prop: string
    label: string
    width?: string | number
    formatter?: (prop: string, data: any, value: any, index: number) => number | string | VNode
    p_formatter?: (prop: string, data: any, value: any, index: number) => number | string | VNode
    default?: string | VNode
    sortable?: boolean
    overflow?: boolean
    labelWidth?: string
    show?: (isPhone: boolean) => boolean
}

export interface interCard {
    img: string
    title: string
    tag: string
    price: string
    count: string
    rate?: string
}
export interface interRule {
    [key: string]: {
        rule: 'isRequired' | 'isLength' | 'isRegExp' | 'isNotRegExp' | 'isNumbersize' | 'isIdcard' | 'isPhone', [key: string]: any
    }[]
}

export type interMessageType = 'text' | 'img' | 'store'

export type Action = PopoverAction & { id: number, hasConfirm?: Boolean }